import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(Router)

export function createRouter() {
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/Home.vue')
      },
      {
        path: '/:page',
        name: 'home',
        component: () => import('@/views/Home.vue')
      },
      {
        path: '/more',
        name: 'more',
        component: () => import('@/views/Home.vue')
      },
      {
        path: '/detail/:id',
        name: 'detail',
        /*
          路由只能通过路径传参，通过$route.params.id获取参数
        */
        component: () => import('../views/Detail.vue')
      }
    ]
  })
}
